package com.ehi.tsconfig.service;

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.fasterxml.jackson.databind.ObjectMapper;


@Service
public class TsconfigService {
	private static final Logger logger = LoggerFactory.getLogger(TsconfigService.class);

	public void  createConfigFile(File output, String configJson) {
	    ObjectMapper mapper = new ObjectMapper();
	    try {
	        Object obj = mapper.readValue(configJson, Object.class);
            mapper.writerWithDefaultPrettyPrinter().writeValue(output, obj);
        } catch (IOException e) {
            logger.error("write to config json file error", e);
        }
	}
	
	public ExecuteResult cloneProject(){
	    GitHandler handler = new GitHandler();
	    return handler.createProject(null);
	}
	public List<ExecuteResult> newInstance(){
	    GitHandler handler = new GitHandler();
	    return handler.createNewInstance(null);
	}
}
